/* ======================================================================================== *\

		FILE:				Utils.cpp
		AUTHOR:				Jack Hoxley

		DESCRIPTION:		Provides implementations of the utility functions defined
							in Utils.h

		CHANGE:				5th May 2007
								Basic public interface implemented.
							8th May 2007
								Implemented simple RandomNum class using <cmath>
								Implemented IsInRange()

\* ======================================================================================== */

// Include Standard Headers
// ------------------------
#include "DXUT.h"
#include <cmath>
#include <ctime>

#pragma warning( disable : 4995 ) // Not interested in deprectation warnings
#include <sstream>
#pragma warning( default : 4995 )

// Include project headers
// -----------------------
#include "Utils.h"


namespace Utils
{
	void OutputMessage( MessageClass MsgClass, WCHAR* wcFunction, int iLine, const WCHAR *wcMessage )
	{
		// Compose the string to be displayed
		std::wostringstream woss;

		switch( MsgClass )
		{
			case Warning:
				woss << L"(WARNING)";
				break;

			case Error:
				woss << L"(ERROR)";
				break;

			case Information:
				woss << L"(INFO)";
				break;

			default:
				woss << L"(UNKNOWN)";
		}
		woss << L" : " << wcFunction << L"() @ Line " << iLine << L" : " << wcMessage << std::endl;

		// Output it to the Visual Studio 'output' window (or debugmon from SysInternals)
		OutputDebugString( woss.str().c_str() );

		// Optionally also write it out to a file (NYI)
	}



	int RndInRange( const int& lower, const int& upper )
	{
		return (rand() % (upper-lower)) + lower;
	}
}